﻿using Framework.Models.Entities;
using Framework.Repository;
using Framework.Utility.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Flow.Manage.Contracts;
using Microsoft.EntityFrameworkCore;

namespace Flow.Manage.Service
{
    public class BannerService: IBannerContract
    {
        private readonly IBannerRepository _bannerRepository;
        private readonly IUserRepository _userRepository;

        public BannerService(IBannerRepository bannerRepository, IUserRepository userRepository)
        {
            _bannerRepository = bannerRepository;
            _userRepository = userRepository;
        }
       
        public TData<List<Biz_Banner>> GetAllBanner()
        {   
            TData<List<Biz_Banner>> tData = new TData<List<Biz_Banner>>(); 
            tData.data = _bannerRepository.EntitiesAsNoTracking.ToList();  
            return tData;
        }
        public async Task<TData<List<Biz_User>>> GetAllUser()
        {
            TData<List<Biz_User>> tData = new TData<List<Biz_User>>();
            tData.data = await _userRepository.EntitiesAsNoTracking.ToListAsync();
            tData.total = await _userRepository.EntitiesAsNoTracking.CountAsync();
            return tData;
        }
    }
}
